package com.fyyg.wechat.controller.home;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.fyyg.wechat.base.BaseController;
import com.fyyg.wechat.util.wechat.ShareSecondary;
import com.fyyg.wechat.util.wechat.WechatUtils;

/**
 * @version: v1.0
 * @Description: 首页及其它主页等
 * @author PengYu
 * @date 2018年1月12日 下午6:00:44
 */
@RequestMapping("/index")
@Controller
public class IndexController extends BaseController{
	
	@RequestMapping("/wechat")
	public String wechat(HttpServletRequest request,HttpServletResponse response){
		return "indexwechat";
	}
	/**
	 * 默认商品页面
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping("/indexwechat")
	public ModelAndView indexPage(HttpServletRequest request,HttpServletResponse response){
		String uri = request.getRequestURI();
		String urlParm = request.getQueryString();
		String url = WechatUtils.getAccessUrl(uri, urlParm);
		
		ShareSecondary shareSecondary = new ShareSecondary();
		shareSecondary.setTitle("商品");
		shareSecondary.setContent("活动商品");
		shareSecondary.setImage("");
		shareSecondary.setShareurl(url);
		
		shareSecondary = WechatUtils.getShareSecondary(url, urlParm, shareSecondary);
		Map<String,Object> rslt = new HashMap<String,Object>();
		rslt.put("wechat",shareSecondary);
		return new ModelAndView("indexwechat", rslt);
	}
}
